import { ElMessage } from 'element-plus/es'

/**
 * 复制文本
 * @param text 文本
 */
export const useCopy = (text: string) => {
  const input = document.createElement('input')
  input.value = text
  document.body.appendChild(input)
  input.select()
  document.execCommand('Copy')
  document.body.removeChild(input)
  ElMessage.success('复制成功')
}

/*
使用：
import { useCopy } from '@/utils'

const onCLick = (text) => {
    useCopy(text)
}
*/
